package cn.maxhou.mapper;

import cn.maxhou.pojo.Supplier;
import cn.maxhou.utils.MyBatisUtil;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class SupplierMapperTest2 {

    private Logger logger = Logger.getLogger(SupplierMapperTest2.class);

    @Test
    public void testCount() {
       SqlSession sqlSession= MyBatisUtil.createSqlSession();
        int count = sqlSession.getMapper(SupplierMapper.class).Count();

        logger.debug("SupplierMapperTest2.count() ---> " + count);
        MyBatisUtil.closeSqlSession(sqlSession);
    }

    @Test
    public void testSelect() {
        SqlSession sqlSession= MyBatisUtil.createSqlSession();
        List<Supplier> suppliers =sqlSession.getMapper(SupplierMapper.class).selectAll();

        for (Supplier supplier : suppliers) {
            logger.debug(supplier.toString());
        }

        MyBatisUtil.closeSqlSession(sqlSession);
    }
}